package com.shensi.adminCollect.service.system.impl;

import com.shensi.adminCollect.domain.system.SysAgent;
import com.shensi.adminCollect.mapper.system.SysAgentMapper;
import com.shensi.adminCollect.service.system.ISysAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 代理机构Service业务层处理
 *
 * @author qujia
 * @date 2021-07-01
 */


@Service
public class SysAgentServiceImpl implements ISysAgentService
{
    @Autowired
    private SysAgentMapper sysAgentMapper;

    /**
     * 查询代理机构
     *
     * @param id 代理机构ID
     * @return 代理机构
     */
    @Override
    public SysAgent selectSysAgentById(Integer id)
    {
        return sysAgentMapper.selectSysAgentById(id);
    }

    /**
     * 查询代理机构列表
     *
     * @param sysAgent 代理机构
     * @return 代理机构
     */
    @Override
    public List<SysAgent> selectSysAgentList(SysAgent sysAgent)
    {
        return sysAgentMapper.selectSysAgentList(sysAgent);
    }

    @Override
    public List<Integer> sysAgentlist(SysAgent sysAgent)
    {
        List<SysAgent> list = sysAgentMapper.selectSysAgentList(sysAgent);
        List<Integer> intList =new ArrayList<>();
        if(list!=null && list.size()>0){
            for(SysAgent agent:list){
                if(agent.getGroupId()!=null) {
                    intList.add(agent.getGroupId().intValue());
                }
            }
        }
        return intList;
    }
    /**
     * 新增代理机构
     *
     * @param sysAgent 代理机构
     * @return 结果
     */
    @Override
    public int insertSysAgent(SysAgent sysAgent)
    {
        return sysAgentMapper.insertSysAgent(sysAgent);
    }

    /**
     * 修改代理机构
     *
     * @param sysAgent 代理机构
     * @return 结果
     */
    @Override
    public int updateSysAgent(SysAgent sysAgent)
    {
        return sysAgentMapper.updateSysAgent(sysAgent);
    }

    /**
     * 批量删除代理机构
     *
     * @param ids 需要删除的代理机构ID
     * @return 结果
     */
    @Override
    public int deleteSysAgentByIds(Integer[] ids)
    {
        return sysAgentMapper.deleteSysAgentByIds(ids);
    }

    /**
     * 删除代理机构信息
     *
     * @param id 代理机构ID
     * @return 结果
     */
    @Override
    public int deleteSysAgentById(Integer id)
    {
        return sysAgentMapper.deleteSysAgentById(id);
    }

    @Override
    public SysAgent selectSysAgent(SysAgent agent) {
        return sysAgentMapper.selectSysAgent(agent);
    }

    @Override
    public int deleteSysAgent(SysAgent sysAgent) {
        return sysAgentMapper.deleteSysAgent(sysAgent);
    }
}
